﻿@model DictionaryEntity
<form class="layui-form" asp-controller="Plus" asp-action="ChoicesetManage" method="post">
	<div class="row cl">
		<label class="form-label col-xs-3 col-sm-2">
			<ul id="ulNavList" class="Huifold">
				<li class="item">
					<h4>联系人信息表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Contacter&FieldName=Income">月收入</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Contacter&FieldName=Education">学历</a></li>
						</ul>
					</div>
				</li>
				<li class="item">
					<h4>客户联系记录表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ClientLog&FieldName=RelationType">联系方式</a></li>
						</ul>
					</div>
				</li>
				<li class="item">
					<h4>客户信息表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=Area">客户区域</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=ClientField">所属行业</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=ValueLevel">价值评估</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=CreditLevel">信用等级</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=Importance">重要程度</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=ConnectionLevel">关系等级</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=GroupID">客户组别</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=SourceType">客户来源</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Client&FieldName=PhaseType">客户阶段</a></li>
						</ul>
					</div>
				</li>
				<li class="item">
					<h4>公司信息表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Company&FieldName=StatusInField">行业地位</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Company&FieldName=CompanySize">公司规模</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Company&FieldName=ManagementForms">经营状态</a></li>
						</ul>
					</div>
				</li>
				<li class="item">
					<h4>服务记录表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ServiceLog&FieldName=ServiceType">服务类型</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ServiceLog&FieldName=ServiceMode">服务方式</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ServiceLog&FieldName=TakeTime">花费时间</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ServiceLog&FieldName=Result">服务结果</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ServiceLog&FieldName=ConfirmScore">客户评价</a></li>
						</ul>
					</div>
				</li>
				<li class="item">
					<h4>投诉记录表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ComplainLog&FieldName=ComplainType">服务类型</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ComplainLog&FieldName=ComplainMode">服务方式</a></li>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=ComplainLog&FieldName=ExigenceLevel">紧急程度</a></li>
						</ul>
					</div>
				</li>
				<li class="item">
					<h4>订单表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Orders&FieldName=OrderType">订单类型</a></li>
						</ul>
					</div>
				</li>
				<li class="item">
					<h4>作者表<b>+</b></h4>
					<div class="info" style="display:block;">
						<ul>
							<li><a href="/Admin/Plus/ChoicesetManage?TableName=Author&FieldName=Type">作者类型</a></li>
						</ul>
					</div>
				</li>
			</ul>
		</label>
		<div class="formControls col-xs-9 col-sm-10">
			<div class="cl pd-5 bg-1 bk-gray">
				<span class="l">
					数据字典管理 >> @Model.Title
				</span>
			</div>
			<table class="table table-border table-bordered table-bg table-hover mt-20">
				<thead>
					<tr class="text-c">
						<th width="20%">序号</th>
						<th width="20%">默认</th>
						<th width="20%">启用</th>
						<th width="40%">选项值</th>
					</tr>
				</thead>
				<tbody id="tableBody">
					@{
						var arrValue = Model.FieldValue.Split('$', StringSplitOptions.RemoveEmptyEntries);
						for (var i = 0; i < arrValue.Length + 3; i++)
						{
							var chkID = "chk" + i;
							var txtID = "txt" + i;
							var num = i + 1;
							var arrItemValue = new string[3] { string.Empty, string.Empty, string.Empty };
							if (i < arrValue.Length)
							{
								arrItemValue = arrValue[i].Split('|', StringSplitOptions.RemoveEmptyEntries);
							}
							var txtValue = DataConverter.ToString(arrItemValue[0]);
							var chkValue = DataConverter.CLng(arrItemValue[1]);
							var radValue = DataConverter.CLng(arrItemValue[2]);
							<tr class="text-c">
								<td>@num</td>
								<td>
									@if (radValue == 1)
									{
										<input type="radio" name="rad" value="@i" checked="checked" />
									}
									else
									{
										<input type="radio" name="rad" value="@i" />
									}
								</td>
								<td>
									@if (chkValue == 1)
									{
										<input type="checkbox" name="@chkID" id="@chkID" checked="checked" lay-skin="primary" />
									}
									else
									{
										<input type="checkbox" name="@chkID" id="@chkID" lay-skin="primary" />
									}
								</td>
								<td><input type="text" class="input-text" name="@txtID" id="@txtID" value="@txtValue" /></td>
							</tr>
						}
					}
				</tbody>
			</table>
			<div class="cl pd-5 bg-1 bk-gray mt-20 text-c">
				<button class="layui-btn layuiadmin-btn-list" type="submit">保存</button>
				<input type="hidden" asp-for="FieldID" />
				<input type="hidden" asp-for="TableName" />
				<input type="hidden" asp-for="FieldName" />
			</div>
		</div>
	</div>
	@Html.AntiForgeryToken()
</form>

@section scripts{
	<script type="text/javascript">
		function GetChoicesetList() {
			$.ajax({
				type: "GET",
				url: "/Admin/Plus/GetChoicesetList",
				async: false,
				contentType: "application/x-www-form-urlencoded;charset=UTF-8",
				success: function (data) {
					var TableTitle = "";
					var html = "";
					$.each(data, function (i, item) {
						if (html == "") {
							html += "<li class=\"item\"><h4>" + item.TableTitle + "<b>+</b></h4><div class=\"info\" style=\"display: block;\"><ul>";
						} else if (item.TableTitle != TableTitle) {
							html += "</ul></div></li>";
							html += "<li class=\"item\"><h4>" + item.TableTitle + "<b>+</b></h4><div class=\"info\" style=\"display: block;\"><ul>";
						}
						html += "<li>";
						html += "<a href=\"/Admin/Plus/ChoicesetManage?TableName=" + item.TableName + "&FieldName=" + item.FieldName + "\">" + item.Title + "</a>";
						html += "<span class=\"r\"><a href=\"/Admin/Plus/ChoicesetManage?TableName=" + item.TableName + "&FieldName=" + item.FieldName + "\">查看</a>&nbsp;&nbsp;";
						html += "<a href=\"javascript:showFieldEdit(" + item.FieldID + ",'" + item.Title + "');\">编辑</a></span>";
						html += "</li>";
						TableTitle = item.TableTitle;
					});
					$("#ulNavList").html("");
					$("#ulNavList").html(html);
				},
				error: function (data, status, e) {
					layer.msg('得到数据失败!');
				}
			})
		}
		function showFieldEdit(fieldID = 0, fieldTitle = "") {
			if (fieldID <= 0 || fieldTitle == "") {
				layer.msg('指定的字段不存在!');
			}
			layer.prompt({
				formType: 0,
				value: fieldTitle,
				title: '编辑字段名：' + fieldTitle
			}, function (value, index, elem) {
					if (value == null || value == "") {
						layer.msg('字段名不能为空!');
						return false;
					}
					$.ajax({
						type: "POST",
						url: "/Admin/Plus/UpdateChoicesetFieldName",
						data: { "FieldID": fieldID, "FieldTitle": value},
						headers: {
							"X-CSRF-TOKEN-JXWebHost": $("input[name='AntiforgeryFieldname']").val()
						},
						error: function (data, status, e) {
							layer.alert('修改失败!');
						},
						success: function (data) {
							if (data.Result == "ok") {
								layer.msg('修改成功!');
								setTimeout('window.location.reload()', 1000);
							}
							else {
								layer.alert(data.Result);
							}
							layer.close(index);
						}
					});
			});
		}
		$(function () {
			GetChoicesetList();
			$.Huifold("#ulNavList .item h4", "#ulNavList .item .info", "fast", 3, "click");
		});
	</script>
}